package SubjectInstruction;

use Moose;
use Data::Dumper;
use ObjectInstruction;
use Utils;

has 'property' => (
    is => 'rw' ,
    isa => 'Str',
    );

has 'objects' => (
    is => 'rw',
    isa => 'ArrayRef[ObjectInstruction]',
    default => sub { [ ] } ,
    );

has 'line_begin' => (
    is => 'rw',
    isa => 'Int',
    default => 0,
    );

has 'line_end' => (
    is => 'rw',
    isa => 'Int',
    default => 0,
    );

has 'modifiers' => (
    is => 'rw',
    isa => 'HashRef[Bool]',
    default => sub {
	{
	    'clear' => 0,
	    'lock'  => 0,
	}
    } ,
    );


# perform consistencies checks:
sub check {
    
}

sub setModifier {
   my $s = shift;
   my $modifier = shift;
   my $bool = shift;
   if(!exists($s->modifiers->{$modifier})) {
       $s->log->xinternal("b63c2729-2e35-3b07-8eaa-8d0dc2400733",
			     $s->log->format("","","$modifier is not a valid modifier "));
   }
   Utils::defense_valid(__FILE__,__LINE__,'value',$bool,0,1);
   $s->modifiers->{$modifier} = $bool;
}

sub addObjects {
    my $self = shift;
    my $iline = shift;
    Utils::defense_between(__FILE__,__LINE__,'line',$line,
			   $self->line_begin,$self->line_end);
    foreach my $o (@_) {
	push(@{$self->objects},ObjectInstruction->new(value => $o,iline = $iline);
    }
}

sub getObjects {
    my $self = shift;
    return @{$self->objects};
}

no Moose;
__PACKAGE__->meta->make_immutable;
